package com.hspedu.threaduse;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/3/10
 * @time 12:20
 */
public class Thread04 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new Task());
        new Thread(futureTask).start();
        Thread.sleep(5000);
        Integer integer = futureTask.get();
        System.out.println(integer);
    }
}

class Task implements Callable<Integer>{
    @Override
    public Integer call() throws Exception {
        Thread.sleep(3000);
        return 1;
    }
}
